package com.dinzeer.resonantisshelomoh.regsiter;

import com.dinzeer.legendreliclib.lib.compat.slashblade.SlashBladeCreativeTap;
import mods.flammpfeil.slashblade.SlashBladeCreativeGroup;
import mods.flammpfeil.slashblade.init.SBItems;
import mods.flammpfeil.slashblade.item.ItemSlashBlade;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.RegistryObject;

import java.util.List;

import static com.dinzeer.resonantisshelomoh.Resonantisshelomoh.MODID;

public class CreativeTab {
    public static final DeferredRegister<CreativeModeTab> REGISTRY = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MODID);
    public static final RegistryObject<CreativeModeTab> Slashblade = REGISTRY.register("solomen_slashblade",
            () -> CreativeModeTab.builder()
                    .withTabsBefore(SlashBladeCreativeGroup.SLASHBLADE_GROUP.getId())
                    .title(Component.translatable("item_group.resonantisshelomoh.solomen_slashblade")).icon(() -> {
                        ItemStack stack = new ItemStack(SBItems.slashblade);
                        stack.getCapability(ItemSlashBlade.BLADESTATE).ifPresent(s -> {
                            s.setModel(new ResourceLocation(MODID, "model/speed/speed.obj"));
                            s.setTexture(new ResourceLocation(MODID, "model/speed/speed.png"));
                        });
                        return stack;
                    })
                    .displayItems((parameters, tabData) -> {
                        List<Item> items=RSitemRegsitry.ITEMS.getEntries().stream().map(RegistryObject::get).toList();
                        for (Item item : items) {
                            tabData.accept(item);
                        }
                    })
                    .build());
}
